package com.qcit.older.usercenter.common

import android.text.TextUtils
import com.qcit.common.utils.QSharedPreferences
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

class QRequesterAuthInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        var auth = ""
        QSharedPreferences.user?.let {
            auth=it.authorization
        }
        if (auth == null) auth = ""
        var builder = chain.request().newBuilder()
        if (!TextUtils.isEmpty(auth)) {
            builder.addHeader("Authorization", auth)
        }
//        if (QSharedPreferences.user != null && QSharedPreferences!!.user!!.info != null
//            && QSharedPreferences!!.user!!.info.elderList != null
//            && QSharedPreferences!!.user!!.info.elderList.size > 0){
//            builder.addHeader("elderCommunityId", QSharedPreferences!!.user!!.info.elderList[0].communityId.toString())
//        }
//        builder.addHeader("macKey", DeviceIdUtils.getDeviceId(BaseApplication.sApplication))
        val request: Request = builder.build()
        return chain.proceed(request);
    }

}